package com.jiyun.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiyun.mapper.ConsumerMapper;
import com.jiyun.model.Consumer;
import com.jiyun.model.User;
import com.jiyun.service.ConsumerService;
import com.jiyun.vo.ConsumerDto;
import com.jiyun.vo.ConsumerVo;
import com.jiyun.vo.ResultResopnse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/* *
 * @Author nxj
 * @Date 2023 08 2023/8/11 14 48
 * */
@Service
public class ConsumerServiceImpl extends ServiceImpl<ConsumerMapper, Consumer> implements ConsumerService {
@Autowired
private ConsumerMapper consumerMapper;

    @Override
    public ResultResopnse login(User user) {
        LambdaQueryWrapper<Consumer> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Consumer::getUsername,user.getUsername());
        Consumer one = consumerMapper.selectOne(lambdaQueryWrapper);
        if (one==null){
            ResultResopnse<Object> error = ResultResopnse.error();
            error.setMessage("用户名错误");
            return error;
        }
        if (!one.getPassword().equals(user.getPassword())){
            ResultResopnse<Object> error = ResultResopnse.error();
            error.setMessage("密码错误");
            return error;
        }

        return ResultResopnse.success(null);
    }
}
